from wxpyview.ui.component.common.basewidget import *

class FileDialog(Widget):
    def _getParentParam(self, meta_widget):
        # TODO: re-implementation
        return None
    
    def _setParams(self, meta_widget):
        dom = meta_widget.getDOM()
        if not dom:
            raise IOException
        
        self.params["parent"] = self._getParentParam(meta_widget)
        self.params["message"] = WidgetLib.getDomAttr(dom, "title", wx.FileSelectorPromptStr)
        self.params["defaultDir"] = WidgetLib.getDomAttr(dom, "defaultDir", wx.EmptyString)
        self.params["defaultFile"] = WidgetLib.getDomAttr(dom, "defaultFile", wx.EmptyString)
        self.params["wildcard"] = WidgetLib.getDomAttr(dom, "wildcard", wx.FileSelectorDefaultWildcardStr)
        self.params["style"] = WidgetLib.getDomAttr(dom, "style", wx.FD_DEFAULT_STYLE)
        self.params["pos"] = WidgetLib.getPosParam(dom)
    
    def create(self, meta_widget):
        self._setParams(meta_widget)

        return wx.FileDialog(**self.params)